package cn.hd.controller;

import cn.hd.entity.AuthAdvertise;
import cn.hd.entity.Result;
import cn.hd.service.AuthAdvertiseService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
@CrossOrigin
public class AuthAdvertiseController {
    @Autowired
    private AuthAdvertiseService authAdvertiseService;

    @RequestMapping("/selectAllFenYeAuthAdvertise")
    public Object selectAllFenYeAuthAdvertise(int pageNum,int pageSize,String sadname){
        Map map=new HashMap();
        map.put("sadname",sadname);
        PageInfo<AuthAdvertise> page = authAdvertiseService.selectAllFenYeAuthAdvertise(map, pageNum, pageSize);
        if(page.getList().size()!=0){
            return new Result("200","查询成功！",page);
        }else {
            return new Result("400","查询失败！",null);
        }
    }

    @RequestMapping("/selectAuthAdvertiseById")
    public Object selectAuthAdvertiseById(long sadid){
        AuthAdvertise authAdvertise = authAdvertiseService.selectAuthAdvertiseById(sadid);
        if(authAdvertise!=null){
            return new Result("200","查询成功！",authAdvertise);
        }else {
            return new Result("400","查询失败！",null);
        }
    }

    @RequestMapping("/updateAuthAdvertiseStatusPass")
    public Result updateAuthAdvertiseStatusPass(long sadid){
        int i = authAdvertiseService.updateAuthAdvertiseStatusPass(sadid);
        if(i!=0){
            return new Result("200","修改成功！",null);
        }else{
            return new Result("400","修改失败！",null);
        }
    }

    @RequestMapping("/updateAuthAdvertiseStatusFail")
    public Result updateAuthAdvertiseStatusFail(long sadid){
        int i = authAdvertiseService.updateAuthAdvertiseStatusFail(sadid);
        if(i!=0){
            return new Result("200","修改成功！",null);
        }else{
            return new Result("400","修改失败！",null);
        }
    }

}
